package com.huawei.appgallery.forum.cards.card;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.huawei.appgallery.forum.base.card.ForumCard;
import com.huawei.appgallery.forum.base.card.bean.Section;
import com.huawei.appgallery.forum.cards.bean.ForumFollowCardBean;
import com.huawei.appgallery.forum.section.api.ISectionDetailActivityProtocol;
import com.huawei.appgallery.forum.section.api.ISectionDetailActivityResult;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import huawei.widget.HwButton;
import huawei.widget.HwTextView;
import o.azb;
import o.bqy;
import o.bst;
import o.bsy.c;
import o.bsy.d;
import o.bsy.e;
import o.bsy.h;
import o.bsy.j;
import o.bwx;
import o.cgz;
import o.cil;
import o.cim.a;
import o.eqx;
import o.evf;
import o.fho;
import o.fiu;
import o.fjb;
import o.fjc;
import o.fjo;
import o.fjq;
import o.fjt;

public class ForumFollowCard extends ForumCard implements OnClickListener {
    private View ʼ;
    private HwTextView ˊ;
    private HwButton ˋ;
    private ImageView ˎ;
    protected Section ˏ;
    private HwTextView ॱ;

    public ForumFollowCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ʽ(view);
        RelativeLayout relativeLayout = (RelativeLayout) view.findViewById(c.ꓸ);
        azb.ˏ(view, c.ꓸ);
        relativeLayout.setOnClickListener(this);
        this.ˎ = (ImageView) view.findViewById(c.ᐝˊ);
        this.ˊ = (HwTextView) view.findViewById(c.ꜟ);
        this.ॱ = (HwTextView) view.findViewById(c.ꜞ);
        this.ˋ = (HwButton) view.findViewById(c.ᶥ);
        this.ˋ.setOnClickListener(this);
        this.ʼ = view.findViewById(c.ᐨ);
        ˎ();
        return this;
    }

    protected void ˎ() {
        azb.ˋ(this.ʼ, (azb.ˊ(this.ʼॱ) + this.ʼॱ.getResources().getDimensionPixelSize(e.ˏ)) + this.ʼॱ.getResources().getDimensionPixelSize(e.ˊ), azb.ˏ(this.ʼॱ));
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean instanceof ForumFollowCardBean) {
            super.ˏ(cardBean);
            ForumFollowCardBean forumFollowCardBean = (ForumFollowCardBean) cardBean;
            this.ˏ = forumFollowCardBean.ˊ();
            if (this.ˏ != null) {
                eqx.ˏ(this.ˎ, this.ˏ.ॱ(), "app_default_icon");
                this.ˊ.setText(this.ˏ.ˏ());
                ˏ(this.ˏ.ᐝ());
                ʻ();
                if (forumFollowCardBean.ॱᐨ()) {
                    ˏ(this.ʼ, 8);
                } else {
                    ˏ(this.ʼ, 0);
                }
            }
        }
    }

    public void onClick(View view) {
        if (view.getId() == c.ꓸ) {
            ʽ();
        } else if (view.getId() == c.ᶥ) {
            ॱॱ();
        }
    }

    private void ʽ() {
        if (this.ˏ != null) {
            cil.ˋ(this.ʼॱ, new a().ˊ(this.ˏ.ॱॱ()).ˋ());
            fjb ˎ = fho.ˏ().ˋ("Section").ˎ("section_detail_activity");
            ((ISectionDetailActivityProtocol) ˎ.ˊ()).setUri(this.ˏ.ॱॱ());
            fiu.ˊ().ॱ(this.ʼॱ, ˎ, new fjc<ISectionDetailActivityResult>(this) {
                final /* synthetic */ ForumFollowCard ˎ;

                {
                    this.ˎ = r1;
                }

                public /* synthetic */ void ˎ(int i, Object obj) {
                    ˏ(i, (ISectionDetailActivityResult) obj);
                }

                public void ˏ(int i, ISectionDetailActivityResult iSectionDetailActivityResult) {
                    if (i == -1 && iSectionDetailActivityResult != null && iSectionDetailActivityResult.getSection() != null) {
                        this.ˎ.ˏ(iSectionDetailActivityResult.getSection().ᐝ());
                        this.ˎ.ʻ();
                    }
                }
            });
        }
    }

    private void ॱॱ() {
        int i = 0;
        if (this.ˏ != null && 1 == this.ˏ.ᐝ()) {
            i = 1;
        }
        ((bwx) fho.ˏ().ˋ("Operation").ॱ(bwx.class)).ˏ(this.ʼॱ, this.ˏ, i, bqy.ˋ().ˎ()).ˋ(fjt.ˎ(), new fjq<Boolean>(this) {
            final /* synthetic */ ForumFollowCard ˋ;

            public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                if (!o_fjo_java_lang_Boolean.ˊ() || !((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                    return;
                }
                if (i == 0) {
                    this.ˋ.ˏ(1);
                    this.ˋ.ʻ();
                    return;
                }
                this.ˋ.ˏ(0);
                this.ˋ.ʻ();
            }
        });
    }

    protected void ˏ(int i) {
        this.ˏ.ˏ(i);
        if (i == 1) {
            this.ˋ.setText(j.ॱॱ);
            evf.ˋ(this.ˋ, d.ˋ);
            return;
        }
        this.ˋ.setText(j.ॱˊ);
        evf.ˋ(this.ˋ, d.ॱ);
    }

    private void ˏ(View view, int i) {
        if (i != view.getVisibility()) {
            view.setVisibility(i);
        }
    }

    private void ʻ() {
        String quantityString = this.ʼॱ.getResources().getQuantityString(h.ˋ, Long.valueOf(this.ˏ.ˎ()).intValue(), new Object[]{bst.ॱ(this.ʼॱ, this.ˏ.ˎ())});
        String string = this.ʼॱ.getResources().getString(j.ॱˎ, new Object[]{bst.ॱ(this.ʼॱ, (long) this.ˏ.ʻ())});
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(quantityString).append("  ").append(string);
        this.ॱ.setText(stringBuilder.toString());
    }
}
